// pages/login/login.js
import userLogin from "../../api/userLogin";
import RunData from "../../config/runData";
import Keys from "../../config/keys";

Page({
    /**
     * 页面的初始数据
     */
    data: {
        idNum: "",
        pwd: ""
    },
    idNum: function(e){
        this.setData({
            idNum: e.detail.value
        });
    },
    pwd: function(e){
        this.setData({
            pwd: e.detail.value
        });
    },
    login: function() {
        if(this.data.idNum.length<15 || this.data.pwd.length<6){
            wx.showToast({title: '请输入正确内容', icon: 'none'});
            return
        }
        wx.showLoading({
            title: '加载中',
        });
        new userLogin(this.data.idNum, this.data.pwd).http((data) => {
            RunData.MyUserInfo = data;
            RunData.sessionId = data.sessionId;
            wx.setStorage({
                key:Keys.MyUserInfo,
                data:data,
                complete:()=>{
                    wx.navigateBack();
                }
            })
        })
    }
});